﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Objects;
using Northwind.NET.Model;
using Northwind.NET.Settings;

namespace Northwind.NET.EDM.FE.WinForms.Controls
{
    public partial class ProductsUserControl: BaseUserControl
    {
        public ProductsUserControl()
        {
            InitializeComponent();
        }

        public override string FormCaption { get { return Settings.Resources.ProductsFormCaption; } }
        public override dynamic GetEntitySet(ObjectContext context)
        {
            return context.CreateObjectSet<Model.Product>();
        }

        public override BindingSource UserControlBindingSource { get { return productBindingSource; } }

        internal override void SetBindingSource()
        {
            // it has to be used here, if BaseUserControl's code is used then
            // categoryId binding fails
            _context = Globals.CreateObjectContext();
            productBindingSource.DataSource = GetEntitySet(_context);

            supplierСomboBox.DataSource = _context.CreateObjectSet<Model.Supplier>();
            categoryComboBox.DataSource = _context.CreateObjectSet<Model.Category>(); 
        }

        private void previewProductListButton_Click(object sender, EventArgs e)
        {
            todo();
        }
    }
}